# author: alex
# time: 2022/4/29 20:21
import ddt
import pandas as pd
import unittest
import requests

def readFile():
    file = pd.read_csv('data/register_data.csv')
    df = pd.DataFrame(file).fillna('')
    da=df.to_dict(orient='records')
    return da

@ddt.ddt
class Register_interface_test(unittest.TestCase):

    def setUp(self) -> None:
        self.url='http://127.0.0.1:8081/user/register'

    @ddt.data(*readFile())
    def test_login(self,data):
        dic = {
            'phonenumber': data.get('phonenumber'),
            'password': data.get('password'),
            'username': data.get('username'),
            'email': data.get('email')
        }
        res=requests.post(self.url,data=data)
        if data.get('state')==1:
            self.assertEqual(res.status_code,200)
        else:
            self.assertNotEqual(res.status_code,200)


    def tearDown(self) -> None:
        pass

if __name__=='__main__':
    unittest.main()